package com.oig.sys.workflow.vo;


import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

/**
 * 飞书审批实例信息
 */
@Getter
@Setter
@ToString
public class InstanceAllInfoVo {
    @Schema(description = "审批定义编码")
    private String approvalCode;
    @Schema(description = "审批名称")
    private String approvalName;
    @Schema(description = "实例开始时间")
    private String startTime;
    @Schema(description = "实例结束时间=0 未结束")
    private String endTime;
    @Schema(description = "实例创建人Id 工号")
    private String userId;
    @Schema(description = "审批单编号")
    private String serialNumber;
    /**
     * PENDING：审批中
     * APPROVED：通过
     * REJECTED：拒绝
     * CANCELED：撤回
     * DELETED：删除
     */
    @Schema(description = "审批实例状态 PENDING：审批中 APPROVED：通过 REJECTED：拒绝 CANCELED：撤回 DELETED：删除")
    private String status;
    @Schema(description = "审批实例编码")
    private String instanceCode;
    @Schema(description = "单据是否被撤销")
    private boolean reverted;

    /**
     * 审批流详情原始数据
     */
    @Schema(description = "审批流详情原始表单数据")
    private String detailRaw;

    @Schema(description = "实例任务列表")
    private List<InstanceTask> taskList;

    @Schema(description = "实例审批动态")
    private List<InstanceTimeline> timeline;


    @Getter
    @Setter
    @ToString
    public static class InstanceTask{
        @Schema(description = "任务id")
        private String id;
        @Schema(description = "节点id")
        private String nodeId;
        @Schema(description = "节点名称")
        private String nodeName;
        @Schema(description = "节点自定义id")
        private String customNodeId;
        /**
         * AND：会签
         * OR：或签
         * AUTO_PASS：自动通过
         * AUTO_REJECT：自动拒绝
         * SEQUENTIAL：按顺序
         */
        @Schema(description = "审批方式  AND：会签 OR：或签 AUTO_PASS：自动通过 AUTO_REJECT：自动拒绝 SEQUENTIAL：按顺序")
        private String type;
        /**
         * PENDING：审批中
         * APPROVED：通过
         * REJECTED：拒绝
         * TRANSFERRED：已转交
         * DONE：完成
         */
        @Schema(description = "任务状态 任务状态枚举：PENDING：审批中;APPROVED：通过;REJECTED：拒绝;TRANSFERRED：已转交;DONE：完成")
        private String status;
        @Schema(description = "审批人的 user_id，自动通过、自动拒绝时该参数返回值为空。这里是工号")
        private String userId;
        @Schema(description = "审批任务的开始时间，毫秒级时间戳。")
        private String startTime;
        @Schema(description = "审批任务的完成时间，毫秒级时间戳。未完成时返回 0。")
        private String endTime;
    }

    @Getter
    @Setter
    @ToString
    public static class InstanceTimeline{
        /**
         * START：审批开始
         * PASS：通过
         * REJECT：拒绝
         * AUTO_PASS：自动通过
         * AUTO_REJECT：自动拒绝
         * REMOVE_REPEAT：去重
         * TRANSFER：转交
         * ADD_APPROVER_BEFORE：前加签
         * ADD_APPROVER：并加签
         * ADD_APPROVER_AFTER：后加签
         * DELETE_APPROVER：减签
         * ROLLBACK_SELECTED：指定回退
         * ROLLBACK：全部回退
         * CANCEL：撤回
         * DELETE：删除
         * CC：抄送
         */
        @Schema(description = "动态类型")
        private String type;
        @Schema(description = "发生时间")
        private String createTime;
        @Schema(description = "抄送人列表")
        private List<String> ccUserList;
        @Schema(description = "理由")
        private String comments;
        @Schema(description = "执行操作人")
        private String userId;
        @Schema(description = "理由")
        private String taskId;
        @Schema(description = "产生审批任务的节点 key")
        private String nodeKey;
        @Schema(description = "审批附件")
        private List<InstanceFile> fileList;
    }

    @Getter
    @Setter
    @ToString
    public static class InstanceFile{
        @Schema(description = "附件路径")
        private String url;
        @Schema(description = "附件标题")
        private String title;
        @Schema(description = "附件类别 image：图片 attachment：附件，与上传时选择的类型一致")
        private String type;
        @Schema(description = "附件大小。单位：字节")
        private Integer fileSize;
    }

}
